package org.cuckoos.android.command;

import java.net.DatagramSocket;

import org.cuckoos.android.domain.Command;
import org.cuckoos.android.domain.Constant;
import org.cuckoos.android.domain.User;

public class ReciveMsgCommand extends AbstractCommand{

	private Command rmc;

	public ReciveMsgCommand(DatagramSocket ds) {
		super(ds);
	}
	
	public ReciveMsgCommand(DatagramSocket ds, User user,
			String msg){
		super(ds);
		rmc = new Command(user,Constant.IPMSG_RECVMSG,msg);
	}

	@Override
	public void execute() {
		this.execute(rmc);
	}

	@Override
	public void handle(Command ac) {
		int packet = ac.getPacketId();
		ReciveMsgCommand rmc = new ReciveMsgCommand(this.ds,ac.getUser(),String.valueOf(packet));
		rmc.execute();
	}

	@Override
	public boolean isHandle(Command ac) {
		return Constant.IPMSG_SENDCHECKOPT == Constant.GET_OPT(ac.getCommand());
	}

}
